<template>
  <div class="rkContent">
    <div class="rkTitle">
      <!-- <div class="customerTitle">海川医药质管部入库{{ systemTime }}日报</div>
       -->
      <div class="customerTitle">海川医药质管部入库{{ dateTransfer }}日报</div>
      <!-- <div class="searchBtn">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="date"
        ></el-date-picker>
        <el-button type="success" @click="handlerkSearch">搜索</el-button>
      </div> -->
    </div>
    <div class="rkTable">
      <div class="customtr1">
        <div class="customText">类型</div>
        <div class="delivery">
          <div class="deliveryTop">入库</div>
          <div class="deliveryBottom">
            <div class="noendTime">普药</div>
            <div class="endTime">结束时间</div>
            <div class="noendTime">中药</div>
            <div class="endTime">结束时间</div>
            <div class="endTime">异常情况</div>
          </div>
        </div>
        <div class="deliveryright">
          <div class="deliveryTop">检验报告</div>
          <div class="deliveryBottomRight">
            <div>检验报告</div>
            <div>异常情况</div>
            <div>结束时间</div>
          </div>
        </div>
        <!-- <div class="customText">备注(当日异常)</div>
      <div class="completeText">完成时间点</div> -->
      </div>
      <div class="customExtra">
        <div class="customText wyLayout">货主</div>
        <div class="customTextchild wyLayout">条目</div>
        <div class="customTextchild wyLayout">件数</div>
        <div class="endTime wyLayout">/</div>
        <div class="customTextchild wyLayout">条目</div>
        <div class="customTextchild wyLayout">件数</div>
        <div class="endTime wyLayout">/</div>
        <div class="endTime wyLayout">条目</div>
        <div class="testReport wyLayout">张数</div>
        <div class="testReport wyLayout">条目</div>
        <div class="testReport wyLayout noborder">/</div>
      </div>
      <div class="customExtra">
        <div class="customText wyLayout">海通</div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatepytmTotal"
            v-model="reform.htPyTm"
            size="medium"
          />
        </div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatepyjsTotal"
            v-model="reform.htPyJs"
            size="medium"
          />
        </div>
        <div class="endTime wyLayout endTimetop">
          <el-time-picker
            v-model="reform.htwyPyTime"
            placeholder=""
            value-format="HH:mm"
            format="HH:mm"
          >
          </el-time-picker>
        </div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatezytmTotal"
            v-model="reform.htZyTm"
            size="medium"
          />
        </div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatezyjsTotal"
            v-model="reform.htZyJs"
            size="medium"
          />
        </div>
        <div class="endTime wyLayout endTimetop">
          <el-time-picker
            v-model="reform.htwyZyTime"
            placeholder=""
            value-format="HH:mm"
            format="HH:mm"
          >
          </el-time-picker>
        </div>
        <div class="endTime wyLayout">
          <el-input
            @input="calculaterktmTotal"
            v-model="reform.htRkTm"
            size="medium"
          />
        </div>
        <div class="testReport wyLayout">
          <el-input
            @input="calculatejybgzsTotal"
            v-model="reform.htJybgZs"
            size="medium"
          />
        </div>
        <div class="testReport wyLayout">
          <el-input
            @input="calculatejybgtmTotal"
            v-model="reform.htJybgTm"
            size="medium"
          />
        </div>
        <div class="testReport wyLayout noborder endTimetop">
          <el-time-picker
            v-model="reform.thTime"
            placeholder=""
            value-format="HH:mm"
            format="HH:mm"
          >
          </el-time-picker>
        </div>
      </div>
      <div class="customExtra">
        <div class="customText wyLayout">伟业</div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatepytmTotal"
            v-model="reform.wyPyTm"
            size="medium"
          />
        </div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatepyjsTotal"
            v-model="reform.wyPyJs"
            size="medium"
          />
        </div>
        <div class="endTime wyLayout"></div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatezytmTotal"
            v-model="reform.wyZyTm"
            size="medium"
          />
        </div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatezyjsTotal"
            v-model="reform.wyZyJs"
            size="medium"
          />
        </div>
        <div class="endTime wyLayout"></div>
        <div class="endTime wyLayout">
          <el-input
            @input="calculaterktmTotal"
            v-model="reform.wyRkTm"
            size="medium"
          />
        </div>
        <div class="testReport wyLayout">
          <el-input
            @input="calculatejybgzsTotal"
            v-model="reform.wyJybgZs"
            size="medium"
          />
        </div>
        <div class="testReport wyLayout">
          <el-input
            @input="calculatejybgtmTotal"
            v-model="reform.wyJybgTm"
            size="medium"
          />
        </div>
        <div class="testReport wyLayout noborder"></div>
      </div>
      <div class="customExtra">
        <div class="customText wyLayout">其他货主</div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatepytmTotal"
            v-model="reform.qtPyTm"
            size="medium"
          />
        </div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatepyjsTotal"
            v-model="reform.qtPyJs"
            size="medium"
          />
        </div>
        <div class="endTime wyLayout">
          <el-time-picker
            v-model="reform.qtPyTime"
            placeholder=""
            value-format="HH:mm"
            format="HH:mm"
          >
          </el-time-picker>
        </div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatezytmTotal"
            v-model="reform.qtZyTm"
            size="medium"
          />
        </div>
        <div class="customTextchild wyLayout">
          <el-input
            @input="calculatezyjsTotal"
            v-model="reform.qtZyJs"
            size="medium"
          />
        </div>
        <div class="endTime wyLayout">
          <el-time-picker
            v-model="reform.qtZyTime"
            placeholder=""
            value-format="HH:mm"
            format="HH:mm"
          >
          </el-time-picker>
        </div>
        <div class="endTime wyLayout">
          <el-input
            @input="calculaterktmTotal"
            v-model="reform.qtRkTm"
            size="medium"
          />
        </div>
        <div class="testReport wyLayout">
          <el-input
            @input="calculatejybgzsTotal"
            v-model="reform.qtJybgZs"
            size="medium"
          />
        </div>
        <div class="testReport wyLayout">
          <el-input
            @input="calculatejybgtmTotal"
            v-model="reform.qtJybgTm"
            size="medium"
          />
        </div>
        <div class="testReport wyLayout noborder">
          <el-time-picker
            v-model="reform.qtTime"
            placeholder=""
            value-format="HH:mm"
            format="HH:mm"
          >
          </el-time-picker>
        </div>
      </div>
      <div class="customExtrahj">
        <div class="customText wyLayout">合计</div>
        <div class="customTextchild wyLayout">
          <el-input v-model="pytmTotal" size="medium" disabled />
        </div>
        <div class="customTextchild wyLayout">
          <el-input v-model="pyjsTotal" size="medium" disabled />
        </div>
        <div class="endTime wyLayout"></div>
        <div class="customTextchild wyLayout">
          <el-input v-model="zytmTotal" size="medium" disabled />
        </div>
        <div class="customTextchild wyLayout">
          <el-input v-model="zyjsTotal" size="medium" disabled />
        </div>
        <div class="endTime wyLayout"></div>
        <div class="endTime wyLayout">
          <el-input v-model="rktmTotal" size="medium" disabled />
        </div>
        <div class="testReport wyLayout">
          <el-input v-model="jybgzsTotal" size="medium" disabled />
        </div>
        <div class="testReport wyLayout">
          <el-input v-model="jybgtmTotal" size="medium" disabled />
        </div>
        <div class="testReport wyLayout noborder"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { dailyscreenrk } from "@/api/system/daily";
export default {
  props: {
    dateTransfer: {
      type: String,
    },
  },
  data() {
    return {
      dateRange: new Date().toISOString().split("T")[0],
      // 陕西海通零货条目数
      ids: null,
      systemTime: "",
      pytmTotal: undefined,
      pyjsTotal: undefined,
      zytmTotal: undefined,
      zyjsTotal: undefined,
      rktmTotal: undefined,
      jybgzsTotal: undefined,
      jybgtmTotal: undefined,
      // 伟业
      reform: {
        rbSj: new Date().toISOString().split("T")[0],
        // 海通
        htPyTm: null,
        htPyJs: null,
        htZyTm: null,
        htZyJs: null,
        htRkTm: null,
        htJybgZs: null,
        htJybgTm: null,
        // 伟业
        wyPyTm: null,
        wyPyJs: null,
        wyZyTm: null,
        wyZyJs: null,
        wyRkTm: null,
        wyJybgZs: null,
        wyJybgTm: null,
        // 其他
        qtPyTm: null,
        qtPyJs: null,
        qtZyTm: null,
        qtZyJs: null,
        qtRkTm: null,
        qtJybgZs: null,
        qtJybgTm: null,
        // 时间
        htwyPyTime: "",
        htwyZyTime: "",
        qtPyTime: "",
        qtZyTime: "",
        thTime: "",
        qtTime: "",
      },
    };
  },
  mounted() {
    // 创建一个 Date 对象
    const currentDate = new Date();
    // 获取当前年份
    const year = currentDate.getFullYear();
    // 获取当前月份（注意：月份是从 0 开始计数的，所以需要加 1）
    const month = currentDate.getMonth() + 1;
    // 获取当前日期
    const day = currentDate.getDate();
    // 打印年月日
    this.systemTime = `${year}年${month}月${day}日`;
    // this.getreTodayList();
  },
  beforeDestroy() {},
  methods: {
    addDecimals(...nums) {
      const precision = 1000000; // 保留六位小数
      const sum = nums.reduce(
        (acc, num) => acc + Math.round(num * precision),
        0
      );
      return sum / precision;
    },
    calculatepytmTotal() {
      this.pytmTotal = this.addDecimals(
        Number(this.reform.htPyTm),
        Number(this.reform.wyPyTm),
        Number(this.reform.qtPyTm)
      );
    },
    calculatepyjsTotal() {
      this.pyjsTotal = this.addDecimals(
        Number(this.reform.htPyJs),
        Number(this.reform.wyPyJs),
        Number(this.reform.qtPyJs)
      );
    },
    calculatezytmTotal() {
      this.zytmTotal = this.addDecimals(
        Number(this.reform.htZyTm),
        Number(this.reform.wyZyTm),
        Number(this.reform.qtZyTm)
      );
    },
    calculatezyjsTotal() {
      this.zyjsTotal = this.addDecimals(
        Number(this.reform.htZyJs),
        Number(this.reform.wyZyJs),
        Number(this.reform.qtZyJs)
      );
    },
    calculaterktmTotal() {
      this.rktmTotal = this.addDecimals(
        Number(this.reform.htRkTm),
        Number(this.reform.wyRkTm),
        Number(this.reform.qtRkTm)
      );
    },
    calculatejybgzsTotal() {
      this.jybgzsTotal = this.addDecimals(
        Number(this.reform.htJybgZs),
        Number(this.reform.wyJybgZs),
        Number(this.reform.qtJybgZs)
      );
    },
    calculatejybgtmTotal() {
      this.jybgtmTotal = this.addDecimals(
        Number(this.reform.htJybgTm),
        Number(this.reform.wyJybgTm),
        Number(this.reform.qtJybgTm)
      );
    },
    // 获取收货列表
    handlerkSearch() {
      dailyscreenrk({ rbSj: this.dateTransfer }).then((res) => {
        if (res.data) {
          this.reform = res.data;
          this.pytmTotal = this.addDecimals(
            Number(this.reform.htPyTm),
            Number(this.reform.wyPyTm),
            Number(this.reform.qtPyTm)
          );
          this.pyjsTotal = this.addDecimals(
            Number(this.reform.htPyJs),
            Number(this.reform.wyPyJs),
            Number(this.reform.qtPyJs)
          );
          this.zytmTotal = this.addDecimals(
            Number(this.reform.htZyTm),
            Number(this.reform.wyZyTm),
            Number(this.reform.qtZyTm)
          );
          this.zyjsTotal = this.addDecimals(
            Number(this.reform.htZyJs),
            Number(this.reform.wyZyJs),
            Number(this.reform.qtZyJs)
          );
          this.rktmTotal = this.addDecimals(
            Number(this.reform.htRkTm),
            Number(this.reform.wyRkTm),
            Number(this.reform.qtRkTm)
          );
          this.jybgzsTotal = this.addDecimals(
            Number(this.reform.htJybgZs),
            Number(this.reform.wyJybgZs),
            Number(this.reform.qtJybgZs)
          );
          this.jybgtmTotal = this.addDecimals(
            Number(this.reform.htJybgTm),
            Number(this.reform.wyJybgTm),
            Number(this.reform.qtJybgTm)
          );
        }
      });
    },
    // saveRkdaily() {
    //   dailyaddrk(this.reform).then((res) => {
    //     console.log(res);
    //     this.$modal.msgSuccess("新增成功");
    //     this.getreTodayList();
    //   });
    // },
  },
};
</script>

<style lang="scss" scoped>
.rkContent {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #ffffff;
  ::v-deep .el-table__body-wrapper {
    border: 1px solid #181616;
  }
  ::v-deep .el-table--enable-row-hover .el-table__body tr:hover > td {
    background-color: transparent;
  }
  ::v-deep .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 100%;
  }

  .rkTitle {
    width: 100%;
    text-align: center;
    .customerTitle {
      width: 100%;
      font-size: 24px;
      font-weight: 700;
      margin: 30px 0 20px 0;
    }
    ::v-deep .el-button--success {
      height: 36px;
      margin-left: 30px;
    }
  }
  .rkTable {
    width: 100%;
    margin-top: 20px;
    ::v-deep .el-input__inner {
      height: 65px;
      line-height: 65px;
      border: none;
      text-align: center;
      color: #000000;
      width: 100%;
    }
  }
  .customtr1 {
    width: 100%;
    height: 140px;
    border: 1px solid #e7dfdf;
    background: #05a5ff;
    display: flex;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    justify-content: space-around;
    .customText {
      width: 10%;
      height: 140px;
      line-height: 140px;
      text-align: center;
      border-right: 1px solid #e7dfdf;
    }
    .completeText {
      width: 11.1%;
      height: 140px;
      line-height: 140px;
      text-align: center;
    }
    .delivery {
      width: 60%;
      display: flex;
      flex-direction: column;
      .deliveryTop {
        height: 50%;
        line-height: 70px;
        text-align: center;
        border-right: 1px solid #e7dfdf;
      }
      .deliveryBottom {
        height: 50%;
        display: flex;
        justify-content: space-around;
        border-top: 1px solid #e7dfdf;
        color: #ffffff;
        div {
          height: 100%;
          text-align: center;
          line-height: 70px;
          border-right: 1px solid #e7dfdf;
        }
        .noendTime {
          width: 25%;
        }
        .endTime {
          width: 16.7%;
        }
      }
    }
    .deliveryright {
      width: 30%;
      display: flex;
      flex-direction: column;
      .deliveryTop {
        height: 50%;
        line-height: 70px;
        text-align: center;
        border-right: 1px solid #e7dfdf;
      }
      .deliveryBottomRight {
        height: 50%;
        display: flex;
        justify-content: space-around;
        border-top: 1px solid #e7dfdf;
        color: #ffffff;
        div {
          width: 34%;
          height: 100%;
          line-height: 70px;
          text-align: center;
          border-right: 1px solid #e7dfdf;
        }
      }
    }
  }
  .customExtra {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    // background: #00d9ff;
    display: flex;
    justify-content: space-around;
    .wyLayout {
      font-weight: 700;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    .endTimetop {
      padding-top: 40px;
    }
    .endTimecenter {
      padding-top: 70px;
    }
    .customText {
      width: 10%;
    }
    .customTextchild {
      width: 7.5%;
    }
    .endTime {
      width: 10%;
    }
    .testReport {
      width: 10%;
    }
    .noborder {
      border-right: none !important;
    }
  }
  .customExtrahj {
    background: #75d561;
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    // background: #00d9ff;
    display: flex;
    justify-content: space-around;
    ::v-deep .el-input.is-disabled .el-input__inner {
      background: #75d561;
      font-weight: 700;
      color: #ff4800;
      font-size: 18px;
    }
    .wyLayout {
      font-weight: 700;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    .customText {
      width: 10%;
    }
    .customTextchild {
      width: 7.5%;
    }
    .endTime {
      width: 10%;
    }
    .testReport {
      width: 10%;
    }
    .noborder {
      border-right: none !important;
    }
  }
}
</style>